<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<script type="text/javascript" src="../jquery/jquery-1.11.3.js"></script>
<link rel="stylesheet" href="../CSS/companyJob.css">
	<style >
	 #In-table{
	 	border: 1;
		width:500px;
		height:50px;
		margin-top:20px;
	 }
	 blockquote{
	 	font-size:15px;
	 }
	 #check{
	 	position:fixed;
	 	width:500px;
	 	height:450px;
	 	background:#DDDDDD;
	 	top:150px;
	 	left:400px;
	 	z-index:100;
	 	
	 }
	 .check-title-pic{
	 	width:100px;
	 	margin-left:470px;
	 }
	 .check-title{
		width:100%;
		height:30px;
		background:#AAAAAA;
	 }
	 
	 .check-body{
	 	width:85%;
	 	height:90%;
	 	background:#DDDDDD;
	 	margin-left:44px;
	 	margin-top:-11px;
	 }
	 #Content{
	 	position:relative;
	 }
	 
	 #check ul{
	 	height:100%;
	 	width:250px;
	 	margin-left:130px;
	 	margin-top:25px;
	 }
	 #check li{
	 	list-style-type:none;
	 }
	 input{
	 	width:180px;
	 	height:20px;
	 	margin:5px 3px 5px 3px;
	 }
	 button{
	 	margin-top:10px;
	 	margin-left:50px;
	 	width:60px;
	 }
	</style>
<title>工作岗位</title>
</head>
<body>
	<div id="Header">
		<div class="Header-Logo">
			<a href="http://www.baidu.com">
				<img src="../images/yy.png" alt="YY招聘网">
			</a>
		</div>
		<div class="Header-Logo-Right">
			<ul>
				<li>
					<a id="loginName" href="userResume.html">我的档案</a>
				</li><li>
					<a id="getCompany" href="CompanyInfo.html" >公司</a>
				</li>
			</ul>
		</div>
		<div class="LoginName">
			<h2>你好</h2>
		</div>
	</div>
	<div id="Content">
		<div class="Content-Background"></div>
		<div class="Content-Background-Content">
			
			<div id="Main-Div" >
			</div>
		</div>
		
		<div id="check" style="display:none">
			<div class="check-title">
				<div class="check-title-pic">
					<a href="javascript:void(0)" onClick="closea()">
						<img width="25" height="25" alt="关闭" src="../images/maskdelete.png">
					</a>
				</div>
			</div>
			<div class="check-body">
				<ul>
					<li>
						<blockquote>姓名：</blockquote>
						<input type="text" id="resumeDTO.resumeName" name="resumeDTO.resumeName"/>
					</li>
					<li>
						<blockquote>性别:</blockquote>
						<input type="text" id="resumeDTO.resumeSex" name="resumeDTO.resumeSex"/>
					</li>
					<li>
						<blockquote>学校：</blockquote>
						<input type="text" id="resumeDTO.resumeSchool" name="resumeDTO.resumeSchool"/>
					</li>
					<li>
						<blockquote>联系方式：</blockquote>
						<input type="text" id="resumeDTO.resumePhone" name="resumeDTO.resumePhone"/>
					</li>
					<li>
						<blockquote>个人简介</blockquote>
						<input type="text" id="resumeDTO.resumeIntro" name="resumeDTO.resumeIntro"/>
					</li>
					<li>
						<button onClick="submitResume()">提&nbsp;交</button>
					</li>
				</ul>
			</div>
		</div>
	</div>
	
	
	
	<script >
		var jobId;									//获取的jobId;
		var hs = document.getElementsByTagName("h2");
		var hs_value = hs[0].innerHTML;
		hs[0].innerHTML = "aa";
		alert(localStorage.getItem("loginName2")+"+bbbbbbbbbbbbbbb");
		hs[0].innerHTML = localStorage.getItem("loginName2");
		function getCookie(name){
			var arr =document.cookie.match(new RegExp("(^|)"+name+"=([^;]*)(;|$)"));

		　　		if(arr !=null) return unescape(arr[2]);
		　　		return null;
		}
		alert(getCookie("baobao"));
		var companyId = getCookie("baobao");
		console.log("companyId+"+companyId);
		alert(typeof(companyId));
		var jobcompany =companyId>>0;
		alert(jobcompany);
		
		var jobJson;
		var Num;
		$.ajax({
			type : "GET",
			url: "../job/getAlljob.action?jobDTO.jobCompany="+jobcompany,
			dataType : "json",
			success:function(data){
				jobJson = data;
				
				Num=data.num;
				
				$.makeDiv();
				
			},
			error:function(jqXHR){
				alert("发生错误： "+jqXHR.status);
			}
		});
	
		$.makeDiv=function(){
		for(var i=0;i<Num;i++){
			var mainDiv=document.getElementById("Main-Div");
			var mjobid=jobJson.data[i].jobId;
			var mjobname=jobJson.data[i].jobName;
			var mjobcompany=jobJson.data[i].jobCompany;
			var mjobnum=jobJson.data[i].jobNum;
			var mjobhave=jobJson.data[i].jobHave;
			
			var lDiv = document.createElement("div");
			var rDiv = document.createElement("div");
			var zDiv = document.createElement("div");
			
			lDiv.className = "leftDiv";
			rDiv.className = "rightDiv";
			zDiv.className = "zongDiv";
			
			var jobName = document.createElement("p");
			var jobNum = document.createElement("p");
			var jobHave = document.createElement("p");
			
			var pA=document.createElement("a");
			pA.className="AA";
			pA.innerHTML="投递简历";
			pA.setAttribute("href","javascript:void(0)");
			pA.setAttribute("id",mjobid);
			pA.onclick=function(){
				postJobId("Jid",this.id);
			}
			
			jobName.innerHTML = "岗位名称: "+mjobname;
			jobNum.innerHTML = "总人数: "+mjobnum;
			jobHave.innerHTML = "已有人数: "+mjobhave;
			
			
			lDiv.appendChild(jobName);
			lDiv.appendChild(jobNum);
			lDiv.appendChild(jobHave);
			rDiv.appendChild(pA);
			
			mainDiv.appendChild(zDiv);
			zDiv.appendChild(lDiv);
			zDiv.appendChild(rDiv);
			//mainDiv.appendChild(rDiv);
		}
	}
	function postJobId(name,value2){
		if(document.getElementById("check").style.display == "none"){	//显示出DIV
			document.getElementById("resumeDTO.resumeName").value = "";
			document.getElementById("resumeDTO.resumeSex").value = "";
			document.getElementById("resumeDTO.resumeSchool").value = "";
			document.getElementById("resumeDTO.resumePhone").value = "";
			document.getElementById("resumeDTO.resumeIntro").value = "";
			document.getElementById("check").style.display = "";
		}
		else{
			document.getElementById("check").style.display = "none";
		}
		jobId = value2;
		alert("jobId+"+jobId);
		var Days = 1; //此 cookie 将被保存 1 天
		var exp　= new Date();
		console.log("exp.getTime()+"+exp.getTime());
		exp.setTime(exp.getTime() +Days*24*60*60*1000);

		document.cookie = name +"="+ escape (value2) + ";expires=" + exp.toGMTString();

		//location.href = "CompanyInfo.html";
		
	}
		/*function getCookie(){
			var cookie = {};						//初始化最后要返回的对象
			alert(typeof(cookie));
			var all = document.cookie;
			
			if(all === ""){
				return cookie;
			}
			var list = all.split(","); 				//分离出名/值对
			for(var i=0;i<list.length;i++){
				var cookie2 = list[i];
				var p = cookie2.indexOf("=");		//查找第一个"="符号
				var name = cookie2.substring(0,p);   //获取cookie名字
				var value = cookie2.substring(p+1);	//获取cookie对应的值
				value = unescape(value);			//解码
				cookie["name"] = value;
				//alert()
			}
			return cookie;
		}*/
			
		function closea(){													//关闭浮动的DIV
			if(document.getElementById("check").style.display == ""){
				document.getElementById("check").style.display = "none";
			}
		}
		
		function submitResume(){
			var rName = document.getElementById("resumeDTO.resumeName").value;
			var rSex = document.getElementById("resumeDTO.resumeSex").value;
			var rSchool = document.getElementById("resumeDTO.resumeSchool").value;
			var rPhone = document.getElementById("resumeDTO.resumePhone").value;
			var rIntro = document.getElementById("resumeDTO.resumeIntro").value;
			 var resumeJson={
					"name":	rName,
					"sex" :	rSex,
					"school":rSchool,
					"phone":rPhone,
					"intro":rIntro,
					"jobId":jobId
			};
			var request = new XMLHttpRequest();
			var type = "POST";
			var URL = "../Resume/addResume.action";
			request.open(type,URL);
			
			request.onreadystatechange = function(){
				if(request.readyState===4 && request.status===200){
					var type = request.getResponseHeader("Content-Type");
    				if(type.indexOf("xml")!==-1 && request.responseXML){		//Document对象响应
    					alert("yesss");
    				}
    				else if(type === "application/json"){						//JSON响应	
    					alert("000000000");
    				}
    				else{														//字符串响应
    					var mark = request.responseText;
						if(mark != 0){									//字符串与数字进行比较，先将字符串转换成数字，然后使用转换后值进行比较
							alert("提交成功！");
							document.getElementById("check").style.display = "none";
						}
    				}
				}
			};
			request.setRequestHeader("Content-Type","application/json");
			request.send(JSON.stringify(resumeJson));
			//alert("111111111111");
		}
	</script>
</body>
</html>